Skip to content

Add HTTP command result support for AppHost HTTP commands#15664

Open
davidfowl wants to merge 3 commits intomainfrom
davidfowl/issue-8729-command-results
Open

Add HTTP command result support for AppHost HTTP commands#15664
davidfowl wants to merge 3 commits intomainfrom
davidfowl/issue-8729-command-results

Conversation

@davidfowl
Copy link
Copy Markdown
Collaborator

@davidfowl davidfowl commented Mar 28, 2026

Description

Adds HTTP command result support for AppHost HTTP commands so response bodies can be surfaced in the CLI, dashboard, and generated polyglot SDKs.

This change:

  • introduces HttpCommandResultMode and HttpCommandOptions.ResultMode
  • exports the HTTP command result metadata through ATS using HttpCommandExportOptions so generated SDKs can surface the same behavior
  • keeps the generated TypeScript API flat when a capability already has a single DTO options parameter
  • adds direct unit tests for GetDefaultHttpCommandResultAsync plus integration coverage through WithHttpCommand
  • updates the Stress sample to expose distinct auto, json, and text HTTP command result scenarios
  • refreshes the affected TypeScript, Python, Go, Java, and Rust code-generation snapshots

During review, the temporary ATS DTO rename support was removed. DTO names continue to come from the CLR type name.

Fixes #8729

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings March 28, 2026 03:25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 28, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15664

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15664"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ATS-friendly support for surfacing HTTP command response bodies as command results, enabling exported metadata + generated polyglot projections to describe response handling (JSON/text/auto/none).

Changes:

  • Introduces HttpCommandResultMode and HttpCommandOptions.ResultMode, plus default logic to capture/format HTTP response bodies when opted in.
  • Adds an ATS-specific withHttpCommand export with an ATS-friendly DTO (HttpCommandExportOptions) and updates ATS scanning/codegen to respect [AspireDto(Name=...)].
  • Updates stress playground endpoints and refreshes TypeScript/Go/Java/Python/Rust generation snapshots and tests.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/WithHttpCommandTests.cs Adds unit tests for result-mode behavior and content-type inference.
tests/Aspire.Hosting.RemoteHost.Tests/AtsCapabilityScannerTests.cs Validates withHttpCommand capability export shape + DTO surface.
src/Aspire.Hosting/ApplicationModel/HttpCommandOptions.cs Adds HttpCommandResultMode, ResultMode, and the ATS DTO for export options.
src/Aspire.Hosting/ResourceBuilderExtensions.cs Implements default result capture logic and adds ATS export withHttpCommand.
src/Aspire.Hosting/Ats/AspireDtoAttribute.cs Adds Name to control exported DTO naming.
src/Aspire.TypeSystem/AttributeDataReader.cs Adds parsing support for [AspireDto] data (including Name).
src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs Uses parsed DTO name when producing ATS DTO type info.
src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs Uses scanned DTO names for TS interfaces + supports “direct options DTO” parameters.
src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs Uses scanned DTO names for Python DTOs.
playground/Stress/Stress.AppHost/Program.cs Adds sample HTTP commands demonstrating result modes.
playground/Stress/Stress.ApiService/Program.cs Adds endpoints returning JSON/text to exercise the new result modes.
tests/**/Snapshots/.verified. Updates polyglot SDK/codegen snapshots to include the new capability, DTO, and enum.
Comments suppressed due to low confidence (1)

src/Aspire.Hosting/ResourceBuilderExtensions.cs:2431

  • XML doc has a typo: "succesful" should be "successful".
    /// is not specified, the command will be considered succesful if the response status code is in the 2xx range. Set

return response.IsSuccessStatusCode
? CommandResults.Success()
: CommandResults.Failure($"Request failed with status code {response.StatusCode}");
return await GetDefaultHttpCommandResultAsync(response, commandOptions, context.CancellationToken).ConfigureAwait(false);
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTTP response is used to compute the command result but is never disposed. To avoid holding open the underlying connection/content stream, consider disposing the HttpResponseMessage in a finally after either GetCommandResult completes or the default result logic runs.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidfowl davidfowl force-pushed the davidfowl/issue-8729-command-results branch from 81db386 to abf2a0b Compare March 28, 2026 05:43
davidfowl and others added 2 commits March 27, 2026 22:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@davidfowl davidfowl changed the title Add ATS support for HTTP command results Add HTTP command result support for ATS and polyglot SDKs Mar 28, 2026
@davidfowl davidfowl changed the title Add HTTP command result support for ATS and polyglot SDKs Add HTTP command result support for AppHost HTTP commands Mar 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.

@github-actions
Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 52 recordings uploaded (commit 89a8e97)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateJavaAppHostWithViteApp ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23679147932

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpCommands / Commands should have a way to provide result / copy it to clipboard

2 participants